package com.kfh.ybracelet.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import com.kfh.ybracelet.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Aaron on 15/12/28.
 */
public class EmoAdapter extends PagerAdapter {

    private Context ctx;

    private List<View> views;

    public EmoAdapter(Context ctx) {

        this.ctx = ctx;
        views = new ArrayList<View>();
        views.add(View.inflate(ctx, R.layout.item_emo_vp, null));
        views.add(View.inflate(ctx, R.layout.item_emo_vp, null));
        views.add(View.inflate(ctx, R.layout.item_emo_vp, null));

    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

        container.removeView(views.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        View currentView = views.get(position);
        container.addView(views.get(position));

        GridView gv_emo = (GridView) currentView.findViewById(R.id.gv_emo);
        EmoGrideAdapter emoGrideAdapter = new EmoGrideAdapter(ctx , position);

        gv_emo.setAdapter(emoGrideAdapter);

        return currentView;
    }

    @Override
    public int getCount() {
        return views.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view == o;
    }

}
